<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        h3 {
            padding: 20px 10px;
        }

        li {
            list-style: none;
        }

        .list li {
            line-height: 45px;
            text-indent: 10px;
            border: 1px solid #333;
        }

        .list li+li {
            border-top: 0;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <h3 id="title">批量操作元素</h3>
        <div class="list">
            <li>01</li>
            <li>02</li>
            <li>03</li>
            <li>04</li>
            <li>05</li>
            <li>06</li>
        </div>
        <input type="text" class="year">
    </div>
</body>
<script>
    function getEle(selector) {
        var obj = {
            eles: document.querySelectorAll(".list li"),
            html: function (con) {
                if (arguments.length >= 1) {//有至少一个参数
                    for (var i = 0; i < this.eles.length; i++) {
                        var ele = this.eles[i];
                        ele.innerHTML = con;
                    }
                } else {
                    return this.eles[0].innerHTML;
                }
            },
            text: function (con) {
                if (arguments.length >= 1) {//有至少一个参数
                    for (var i = 0; i < this.eles.length; i++) {
                        var ele = this.eles[i];
                        ele.innerHTML = con;
                    }
                } else {
                    return this.eles[0].innerHTML;
                }
            },
            val: function(con){
                if (arguments.length >= 1) {//有至少一个参数
                    for (var i = 0; i < this.eles.length; i++) {
                        var ele = this.eles[i];
                        ele.innerHTML = con;
                    }
                } else {
                    return this.eles[0].innerHTML;
                }
            }
        }
        return obj;
    }

    var $listLi = getEle(".list li");
    console.log($listLi);
    $listLi.html(123456);

    var $title = getEle("#title");
    console.log($title);
    $title.html(5622);

    var $year = getEle(".year");
    console.log($year);
    $listLi.val(12345656);
</script>

</html>